package net.peelmeagrape.hibernate;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;

import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 *  Any mapping element which accepts a column attribute will alternatively accept a
 * {@link Column} element.
 */
@Retention(RUNTIME)
@XmlElement(name="column")
public @interface Column
{
    @XmlAttribute String name() default "";
    @XmlAttribute int length() default 255;
    @XmlAttribute int precision() default -1;
    @XmlAttribute int scale() default -1;
    /**
     * Default is false, except for id properties.
     * todo: how to map a null id property?
     */
    @XmlAttribute boolean notNull() default false;
    @XmlAttribute boolean unique() default false;
    @XmlAttribute("unique-key") String uniqueKey() default "";
    @XmlAttribute("sql-type") String sqlType() default "";
    @XmlAttribute String index() default "";
    @XmlAttribute String check() default "none";

    Comment[] comment() default {};
}
